<style>
	tr.sub_row{background:#CCC;}
	tr.sub_row td{padding-left:20px;}
</style>
<div style="padding-bottom:20px;" class="button_section">
	<!--<form>
    	<input type="text"><input type="submit" value="search">
    </form>-->
       <div class="left width65p componentheading"><?php echo $page_title;?></div>
         <a class="button" href="<?php echo site_url('locations/add')?>">Add Locations</a>
        <div class="clear"></div>
</div>
<div class="box-header">Locations List</div>
<div class="box table">
    <table width="100%">
        <thead>
          <tr>
                <th width="10%" height="32">ID</th>
                <th width="60%">Location Name</th>
                <th width="30%">Action</th>
          </tr>
       </thead>
       <tbody>
          <?php if(count($locations) > 0): ?>
              <?php foreach($locations as $location) : ?>
                    <tr>
                        <td><?php echo $location->id;?></td>
                        <td><?php echo $location->location_name;?></td>
                        <td><a href="<?php echo site_url('locations/edit/'.$location->id)?>">Edit</a>&nbsp;|&nbsp;<a href="javascript:;" onClick="delete_locations('<?php echo $location->id;?>');">Delete</a></td>
                    </tr>
              <?php endforeach; ?>
              <?php else: ?>
                <tr>
                        <td colspan="3">
                        <div class="error_message">
                            No locations have been added.
                        </div>
                    </td>
                </tr>
          <?php endif; ?>
        </tbody>
    </table>
</div>

<div id="pagination">
	<?php echo $this->pagination->create_links(); ?>
</div>
<script>
	function delete_locations(cid)
	{ 
		if(confirm('Are you sure you want to delete location ID - '+cid+'???'))
		{
			$.post( '<?php echo site_url('locations/delete');?>', {c_id : cid}, function(data){ window.location = '<?php echo current_url();?>';});
		}
	}
</script>